# -*- coding: utf8 -*-

from google.appengine.ext import webapp
import wsgiref.handlers
from yamw import event
from yamw import task
from yamw import contract
from yamw import money
from yamw import note
from yamw import home
import sys

class RestfulMethodMiddleware(object):  
    def __init__(self, app):  
        self.app = app  
   
    def __call__(self, environ, start_response):  
        method = webapp.Request(environ).get('_method')
        if method:  
            environ['REQUEST_METHOD'] = method.upper()
        return self.app(environ, start_response)  


def main():
  application = webapp.WSGIApplication([(r'/', home.HomePage),
                                        (r'/logout', home.LogoutPage),
                                        (r'/reset', home.ResetPage),
                                        (r'/note', note.NoteHomePage),
                                        (r'/contract', contract.ContractHomePage),
                                        (r'/money', money.MoneyHomePage),
                                        (r'/event', event.EventHomePage),
                                        (r'/task',task.TaskHomePage),
                                        (r'/task/(\d+)',task.TaskPage)],
                                        debug=True)
  wsgiref.handlers.CGIHandler().run(RestfulMethodMiddleware(application))

if __name__ == "__main__":
  main()